Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
print("Введите скобочную последовательность")
a = input()
a1 = ""

for i in a:
    if i == "(":
        a1 += i
    if i == ")":
        if len(a1) > 0:
            if a1[len(a1) - 1] == "(":
                a1 = a1[:-1]
    if i == "[":
        a1 += i
    if i == "]":
        if len(a1) > 0:
            if a1[len(a1) - 1] == "[":
                a1 = a1[:-1]
    if i == "{":
        a1 += i
    if i == "}":
        if len(a1) > 0:
            if a1[len(a1) - 1] == "{":
                a1 = a1[:-1]
    if i == "<":
        a1 += i
    if i == ">":
        if len(a1) > 0:
            if a1[len(a1) - 1] == "<":
                a1 = a1[:-1]
    print(a1)

print(a1)

if len(a1) == 0:
    print("верная")
else:
    print("неверная")